package com.fh.List;

//这里是主要展示一下List的三种遍历方式
import java.util.*;

public class list_For {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        //List 接口的实现子类 Vector LinkedList ArrayList
        List list = new ArrayList();
//        List list = new LinkedList();
//        List list = new Vector();
        list.add("jack");
        list.add("tom");
        list.add("smith");
        list.add("北京烤鸭");
        System.out.println("====迭代器=====");
        //1. 迭代器
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Object obj = iterator.next();
            System.out.println(obj);
        }
        System.out.println("====增强for循环=====");
        //2. 增强for循环
        for (Object object :   list) {
            System.out.println(object);
        }
        System.out.println("====普通for循环=====");
        //3. 普通for循环
        for (int i = 0; i <list.size(); i++) {
            System.out.println(list.get(i));
        }

    }
}
